/*
 * FileName: NewsServiceImpl.java
 *
 * Company: 
 * Copyright 2011-2012 (C) Ultrapower Software CO., LTD. All Rights Reserved.
 */
package com.jmeurope.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.jmeurope.dao.NewsDao;
import com.jmeurope.model.News;
import com.jmeurope.service.NewsService;

/**
 * <p>
 * Description: 
 * </p>
 *
 * @author wangwei  leo_java@163.com
 * @version 1.0

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * Dec 27, 2011 7:20:25 PM          wangwei        1.0         To create
 * </p>
 *
 * @since 
 * @see     
 */
@SuppressWarnings("unchecked")
@Service
@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
public class NewsServiceImpl implements NewsService {

	@Autowired
	private NewsDao newsDao;
	@Override
	public Integer addNews(News news) throws Exception {
		return newsDao.insert(news);
	}

	@Override
	public void deleteNewsById(Integer id) throws Exception {
		newsDao.delete(id);
	}


	@Override
	public List<News> getNewsByStatus(Map map) throws Exception {
		return newsDao.getNewsByStatus(map);
	}

	@Override
	public List<News> getNewsByStatusAndUpdateDate(Map map) throws Exception {
		return newsDao.getNewsByStattusAndUpdateDate(map);
	}

	@Override
	public void updateNews(News news) throws Exception {
		newsDao.update(news);
	}

	@Override
	/**
	 * added by shanming 未实现
	 * wangwei实现 
	 * 拿到所有新闻信息
	 */
	public List<News> getAllNews() throws Exception {
		return	newsDao.findAll();
	}
	/**
	 * 通过模块id和新闻状态查询新闻信息
	 * map ：
	 * 		 key：“status”  value： true or false
	 * 	  	 key：“bussinessId”  value：模块id
	 *    	 注意 map的key 必须按照上面定义写法
	 */
	@Override
	public List<News> getNewsByStatusAndBussinessId(Map map) throws Exception {
		return newsDao.getNewsByStattusAndBussinessId(map);
	}

}
